#include "rclcpp/rclcpp.hpp"
#include "base_interface_demo01/msg/stu.hpp"
using base_interface_demo01::msg::Stu;
class ListenerStu: public rclcpp::Node
{
public:
    ListenerStu() : Node("listener_stu_node_cpp")
    {
        RCLCPP_INFO(this->get_logger(),"订阅方创建！");
        subscription_ = this->create_subscription<Stu>("chatter_stu", 
            10,std::bind(&ListenerStu::listener_callback, this,std::placeholders::_1));
        
    }
 private:
    rclcpp::Subscription<Stu>::SharedPtr subscription_ ;
    void listener_callback(const Stu & stu) const
    {
        RCLCPP_INFO(this->get_logger(),"接收订阅消息 (name=%s,age=%d,height%.2f)",stu.name.c_str(),stu.age,stu.height);
    }  
};
int main(int argc, char const *argv[])
{
    rclcpp::init(argc,argv);
    rclcpp::spin(std::make_shared<ListenerStu>());
    rclcpp::shutdown();
    return 0;
}
